<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>配送关系管理</title>
 <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>已设置医疗机构</h1>
        <ol class="breadcrumb">
           <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">目录管理</a></li>
            <li class="active"><a href="#">配送关系管理</a></li>
            <li class="active"><a href="#">设置配送关系</a></li>
        </ol>
    </section>
        <section class="content">
        <div class=" box box-success">
            <div class="box-body">
                <div class="form-inline">  
	                <div class="form-group form-group-xs">
						<label>医疗机构编码：</label> <input class="form-control" type="text" name="hospCode" id="hospCode" placeholder="医疗机构编码"  /> 
					</div>
					<div class="form-group form-group-xs">
						<label>医疗机构名称：</label> <input class="form-control" type="text" name="hospName" id="hospName" placeholder="医疗机构名称" /> 
					</div>
                <div class="form-group form-group-xs">
			            <label for="txtDrugForm">所属地区：</label>
                        <select class="form-control"  id="area1" name="area1" disabled="disabled">
                        <option value="${area.areaId }">${area.areaName }</option>
                        </select>
                         <select class="form-control"  id="area2" name="area2">
                        </select>
                         <select class="form-control"  id="area3" name="area3">
                        </select>
			        </div>              
	                <button type="button" onclick="gridSerch();" class="btn btn-success btn-sm">查&nbsp;询</button>
	            </div>			      
			</div>
		</div>
<div style="margin-top: 5px;"></div>
	<table class="jqgrid" id="gridlist"></table>
<div style="margin-top: 10px;"></div>
<div id="gridpage"></div>
<div class=" box box-warning bottongroup" id="bottongroup">
<label onclick="return removeDel();" class="btn btn-default btn-sm">解除配送关系</label>
			<label  onclick="window.history.go(-1)"   class="btn btn-default btn-sm" >返 回</label>
		</div>
	</section>
<%@ include file="/WEB-INF/component/commonJS.jsp"%>
<script type="text/javascript">
var flag = false;
function removeDel(){
	if(!flag){
		flag = true;
		  var rowIds = $("#gridlist").jqGrid("getGridParam", "selarrrow") || [];
			if (rowIds.length <= 0) {
				$.HN.message.alert("请选择要解除的医疗机构！", "消息", "warn");
				return;
			}
			$.HN.message.confirm("确定解除吗？", '', '').on(function (e) {
	            if (e) {
			var list = "";
			for (var i=0; i<rowIds.length; i++) {
				rowId = rowIds[i];
				list += rowId + ",";
			}
			if (list.length < 1){
				$.HN.message.alert("请选择要解除的医疗机构！", "消息", "warn");
				return;
			}
			list = list.substring(0,list.length - 1);
			$.post("${pageContext.request.contextPath}/baseGoods/removeDel.html", {
				"param" : list,"status":"${status}"
				}, function(result) {
					if (result.success) {
						$.HN.message.alert("解除配送关系成功！", "消息", "success");
						//window.location.href="${ctx}/baseGoods/toProDelDrugList.html";
						flag = false;
						gridSerch();
					} else {
						$.HN.message.alert("操作失败！", "消息", "error");
					}
				}, "json")
	            }
			}); 
		return true;
	}else{
		return flag;
	}
  
}
$(document).ready(function (){
$("#area2").HNSelect({
            	parent_selector: "#area1",  url: "${pageContext.request.contextPath}/selectController/getArea.html", dataid: "ID",defaultText: "<option value=''>请选择</option>",
                func: function () {
                    $("#area3").HNSelect({
                        parent_selector: "#area2", url: "${pageContext.request.contextPath}/selectController/getArea.html", dataid: "ID", defaultText: "<option value=''>请选择</option>",
                        		
                    });
                }
            });
	jQuery("#gridlist").jqGrid({
		url: "${ctx}/baseGoods/getDelRelationHospList.html",
	    mtype: "POST",
		datatype: "json",
		postData:{"delCompCode":"${param.delCompCode}","prodCompCode":"${param.prodCompCode}","area1":"${area.areaId}"},
		autowidth: true,
		//shrinkToFit: false,
		height: 250,
	   	colNames:['',
	   	          '医疗机构编码',
	   	          '医疗机构名称',
	   	          '所属地区',
	   	          '配送范围',
	   	          '状态'
	   	          ],
	   	colModel:[
	   	{name:'del_rel_id',index:'del_rel_id',key:true,hidden:true,width:100,align:"center", sorttype:false,sortable:false},
	   	{name:'hosp_code',index:'hosp_code',width:225,align:"center",sorttype:false,sortable:false},
	   	{name:'hosp_name',index:'hosp_name',width:275, align:"center",sorttype:false,sortable:false},
		{name:'ar_fullname',index:'area_name',width:275,align:"center", sorttype:false,sortable:false},
	   	{name:'del_range',index:'hosp_classify',width:225,align:"center", sorttype:false,sortable:false},
		{name:'status',index:'status',width:125,align:"center", sorttype:false,sortable:false},
	   	],
		gridComplete: function(){
			
		},
		 rowNum: 20,
	     rowList: [10, 20,50,100],
	     rownumbers: true,
	     multiselect:true,
	     pager: "#gridpage",
	     viewrecords: true,
	     caption: "${param.delCompCode}/${compName}",
	     jsonReader: {
	         repeatitems: false,
	         id: "ids"
	     }
	   	
	});
	
	
	
});
function gridSerch(){
	var area3 = $.trim($("#area3").val());
	var	area2 = $.trim($("#area2").val());
	var area1 = $.trim($("#area1").val());
	var hospCode = $.trim($("#hospCode").val());
	var hospName = $.trim($("#hospName").val());
	$("#gridlist").jqGrid('setGridParam',{  
        datatype:'json',
        postData:{
        "area1":area1,
        "area2":area2,
        "area3":area3,
        "hospCode":hospCode,
        "hospName":hospName,
        },
        page:1
    }).trigger("reloadGrid"); //重新载入  
}










	    
</script>
</body>
</html>